//package com.avic.rong.utils;
//
//import android.text.TextUtils;
//
//import com.avic.rongrong.MyApplication;
//import com.avic.rongrong.bean.LogBean;
//import com.avic.rongrong.bean.LogFilterBean;
//import com.avic.rongrong.bean.LogFilterBeanTwo;
//import com.avic.rongrong.bean.LogResultBean;
//import com.avic.rongrong.service.LogService;
//import com.avic.rongrong.service.OpenActivityService;
//import com.google.gson.Gson;
//import com.orhanobut.logger.Logger;
//import com.wzgiceman.rxretrofitlibrary.retrofit_rx.Api.BaseResultEntity;
//import com.wzgiceman.rxretrofitlibrary.retrofit_rx.http.HttpManager;
//import com.wzgiceman.rxretrofitlibrary.retrofit_rx.log.LoggingInterceptor;
//import com.wzgiceman.rxretrofitlibrary.retrofit_rx.utils.AppUtil;
//
//import java.util.Map;
//
//import okhttp3.OkHttpClient;
//import retrofit2.Call;
//import retrofit2.Callback;
//import retrofit2.Response;
//import retrofit2.Retrofit;
//import retrofit2.converter.gson.GsonConverterFactory;
//
///**
// * Creater: Created by wangyz on 2017/10/20.
// * Email: 936804097@qq.com
// */
//
//public class EventLog {
//
//
//    public static void openStart() {
//        LogBean logBean = new LogBean();
//        logBean.setChannel(DeviceUtils.getAppMetaData(MyApplication.getInstance(), ConstantsUtils.UMENG_CHANNEL));
//        logBean.setIdent(DeviceUtils.getIMEString(MyApplication.getInstance()));
//        logBean.setModel(DeviceUtils.getSystemModel());
//        logBean.setNetwork(NetWorkUtils.getNetworkState(MyApplication.getInstance()));
//        logBean.setOperator(DeviceUtils.getNetOperator(MyApplication.getInstance()));
//        logBean.setSystem(DeviceUtils.getSystemVersion());
//        logBean.setTime(DateUtils.getFormatDateTime(System.currentTimeMillis()));
//        logBean.setVersion(DeviceUtils.getVersionName(MyApplication.getInstance()));
//        logBean.setType(ConstantsUtils.LOG_STATUS_START);
//        logBean.setSource("2");
//        logBean.setProvince(SharePreferenceUtils.getInstance(MyApplication.getInstance()).getAsString(ConstantsUtils.LOCATION_PROVINCE, "北京"));
//        logBean.setCity(SharePreferenceUtils.getInstance(MyApplication.getInstance()).getAsString(ConstantsUtils.LOCATION_CITY, "北京市"));
//        logBean.setTargetId("用户启动App");
//        logBean.setIp(NetWorkUtils.getLocalIpAddress());
//        if (MyApplication.getInstance().userLoginBean != null && MyApplication.getInstance().userLoginBean.getResult() != null) {
//            logBean.setUserId(String.valueOf(MyApplication.getInstance().userLoginBean.getResult().getUserId()));
//        }
//        logBean.setFrom(PreferenceUtils.getString(ConstantsUtils.SHARE_BROADCAST_SOURCE, ConstantsUtils.EMPTY_STR));//这个是linkedme的source属性
//
//
//        OkHttpClient.Builder builder = HttpManager.getUnsafeOkHttpClient().newBuilder();
//        builder.addInterceptor(new LoggingInterceptor());
//
//        Retrofit retrofit = new Retrofit.Builder()
//                .client(builder.build())
//                .baseUrl(AppUtil.HTTP_BASE_URL)
//                .addConverterFactory(GsonConverterFactory.create())
//                .build();
//
//        OpenActivityService logService = retrofit.create(OpenActivityService.class);
//        Gson gson = new Gson();
//        Logger.i("json:----------" + gson.toJson(logBean));
//        Call<BaseResultEntity<String>> logCall = logService.logStatus(logBean);
//        logCall.enqueue(new Callback<BaseResultEntity<String>>() {
//            @Override
//            public void onResponse(Call<BaseResultEntity<String>> call, Response<BaseResultEntity<String>> response) {
//                Logger.i("返回值-------------------" + response.body());
//            }
//
//            @Override
//            public void onFailure(Call<BaseResultEntity<String>> call, Throwable t) {
//                Logger.i("失败-------------------" + t.getMessage());
//            }
//        });
//    }
//
//
//    public static void logFilter(String eventType, Map<String, String> eventDetailMap) {
//        if (eventDetailMap == null) {
//            logFilter(eventType);
//        } else {
//            LogFilterBeanTwo logFilterBean = new LogFilterBeanTwo();
//            logFilterBean.setBrowserBrand(DeviceUtils.getSystemModel());
//            logFilterBean.setBrowserVersion(DeviceUtils.getSystemVersion());
//            logFilterBean.setBrowserHeight(String.valueOf(DensityUtils.getWindowHeight2(MyApplication.getInstance())));
//            logFilterBean.setBrowserWith(String.valueOf(DensityUtils.getWindowWidth2(MyApplication.getInstance())));
//            logFilterBean.setCity(SharePreferenceUtils.getInstance(MyApplication.getInstance()).getAsString(ConstantsUtils.LOCATION_CITY, "北京市"));
//            logFilterBean.setIp(NetWorkUtils.getLocalIpAddress());
//            logFilterBean.setCookieId(DeviceUtils.getIMEString(MyApplication.getInstance()));
//            logFilterBean.setCreateTime(DateUtils.getFormatDateTime(System.currentTimeMillis()));
//            logFilterBean.setEventType(eventType);
//            logFilterBean.setEventDetails(eventDetailMap);
//
//            if (MyApplication.getInstance().userLoginBean != null && MyApplication.getInstance().userLoginBean.getResult() != null) {
//                logFilterBean.setNickName(MyApplication.getInstance().userLoginBean.getResult().getNickName());
//                logFilterBean.setUserId(String.valueOf(MyApplication.getInstance().userLoginBean.getResult().getUserId()));
//            }
//
//            logFilterBean.setChannel(DeviceUtils.getAppMetaData(MyApplication.getInstance(), ConstantsUtils.UMENG_CHANNEL));//渠道
//            logFilterBean.setFrom(PreferenceUtils.getString(ConstantsUtils.SHARE_BROADCAST_SOURCE, ConstantsUtils.EMPTY_STR));//这个是linkedMe中的source属性
//
//
//            OkHttpClient.Builder builder = HttpManager.getUnsafeOkHttpClient().newBuilder();
//            builder.addInterceptor(new LoggingInterceptor());
//
//            Retrofit retrofit = new Retrofit.Builder()
//                    .client(builder.build())
//                    .baseUrl(AppUtil.HTTP_BASE_URL)
//                    .addConverterFactory(GsonConverterFactory.create())
//                    .build();
//
//            LogService logService = retrofit.create(LogService.class);
//            Gson gson = new Gson();
//            Logger.i("json:----------" + gson.toJson(logFilterBean));
//            Call<LogResultBean> logCall = logService.logFilterStatus(gson.toJson(logFilterBean));
//            logCall.enqueue(new Callback<LogResultBean>() {
//                @Override
//                public void onResponse(Call<LogResultBean> call, Response<LogResultBean> response) {
//                    Logger.i("返回值-------------------" + response.body());
//                }
//
//                @Override
//                public void onFailure(Call<LogResultBean> call, Throwable t) {
//                    Logger.i("失败-------------------" + t.getMessage());
//                }
//            });
//        }
//    }
//
//
//    public static void logFilter(String eventType, String eventDetail) {
//        if (eventDetail == null) {
//            logFilter(eventType);
//        } else {
//            LogFilterBean logFilterBean = new LogFilterBean();
//            logFilterBean.setBrowserBrand(DeviceUtils.getSystemModel());
//            logFilterBean.setBrowserVersion(DeviceUtils.getSystemVersion());
//            logFilterBean.setBrowserHeight(String.valueOf(DensityUtils.getWindowHeight2(MyApplication.getInstance())));
//            logFilterBean.setBrowserWith(String.valueOf(DensityUtils.getWindowWidth2(MyApplication.getInstance())));
//            logFilterBean.setCity(SharePreferenceUtils.getInstance(MyApplication.getInstance()).getAsString(ConstantsUtils.LOCATION_CITY, "北京市"));
//            logFilterBean.setIp(NetWorkUtils.getLocalIpAddress());
//            logFilterBean.setCookieId(DeviceUtils.getIMEString(MyApplication.getInstance()));
//            logFilterBean.setCreateTime(DateUtils.getFormatDateTime(System.currentTimeMillis()));
//            logFilterBean.setEventType(eventType);
//            if (!TextUtils.isEmpty(eventDetail)) {
//                logFilterBean.setEventDetails(eventDetail);
//            }
//
//            if (MyApplication.getInstance().userLoginBean != null && MyApplication.getInstance().userLoginBean.getResult() != null) {
//                logFilterBean.setNickName(MyApplication.getInstance().userLoginBean.getResult().getNickName());
//                logFilterBean.setUserId(String.valueOf(MyApplication.getInstance().userLoginBean.getResult().getUserId()));
//            }
//
//            logFilterBean.setChannel(DeviceUtils.getAppMetaData(MyApplication.getInstance(), ConstantsUtils.UMENG_CHANNEL));//渠道
//            logFilterBean.setFrom(PreferenceUtils.getString(ConstantsUtils.SHARE_BROADCAST_SOURCE, ConstantsUtils.EMPTY_STR));//这个是linkedMe中的source属性
//
//
//            OkHttpClient.Builder builder = HttpManager.getUnsafeOkHttpClient().newBuilder();
//            builder.addInterceptor(new LoggingInterceptor());
//
//            Retrofit retrofit = new Retrofit.Builder()
//                    .client(builder.build())
//                    .baseUrl(AppUtil.HTTP_BASE_URL)
//                    .addConverterFactory(GsonConverterFactory.create())
//                    .build();
//
//            LogService logService = retrofit.create(LogService.class);
//            Gson gson = new Gson();
//            Logger.i("json:----------" + gson.toJson(logFilterBean));
//            Call<LogResultBean> logCall = logService.logFilterStatus(gson.toJson(logFilterBean));
//            logCall.enqueue(new Callback<LogResultBean>() {
//                @Override
//                public void onResponse(Call<LogResultBean> call, Response<LogResultBean> response) {
//                    Logger.i("返回值-------------------" + response.body());
//                }
//
//                @Override
//                public void onFailure(Call<LogResultBean> call, Throwable t) {
//                    Logger.i("失败-------------------" + t.getMessage());
//                }
//            });
//        }
//    }
//
//    public static void logFilter(String eventType) {
//        LogFilterBean logFilterBean = new LogFilterBean();
//        logFilterBean.setBrowserBrand(DeviceUtils.getSystemModel());
//        logFilterBean.setBrowserVersion(DeviceUtils.getSystemVersion());
//        logFilterBean.setBrowserHeight(String.valueOf(DensityUtils.getWindowHeight2(MyApplication.getInstance())));
//        logFilterBean.setBrowserWith(String.valueOf(DensityUtils.getWindowWidth2(MyApplication.getInstance())));
//        logFilterBean.setCity(SharePreferenceUtils.getInstance(MyApplication.getInstance()).getAsString(ConstantsUtils.LOCATION_CITY, "北京市"));
//        logFilterBean.setIp(NetWorkUtils.getLocalIpAddress());
//        logFilterBean.setCookieId(DeviceUtils.getIMEString(MyApplication.getInstance()));
//        logFilterBean.setCreateTime(DateUtils.getFormatDateTime(System.currentTimeMillis()));
//        logFilterBean.setEventType(eventType);
//
//        if (MyApplication.getInstance().userLoginBean != null && MyApplication.getInstance().userLoginBean.getResult() != null) {
//            logFilterBean.setNickName(MyApplication.getInstance().userLoginBean.getResult().getNickName());
//            logFilterBean.setUserId(String.valueOf(MyApplication.getInstance().userLoginBean.getResult().getUserId()));
//        }
//
//        logFilterBean.setChannel(DeviceUtils.getAppMetaData(MyApplication.getInstance(), ConstantsUtils.UMENG_CHANNEL));//渠道
//        logFilterBean.setFrom(PreferenceUtils.getString(ConstantsUtils.SHARE_BROADCAST_SOURCE, ConstantsUtils.EMPTY_STR));//这个是linkedMe中的source属性
//
//        OkHttpClient.Builder builder = HttpManager.getUnsafeOkHttpClient().newBuilder();
//        builder.addInterceptor(new LoggingInterceptor());
//
//        Retrofit retrofit = new Retrofit.Builder()
//                .client(builder.build())
//                .baseUrl(AppUtil.HTTP_BASE_URL)
//                .addConverterFactory(GsonConverterFactory.create())
//                .build();
//
//        LogService logService = retrofit.create(LogService.class);
//        Gson gson = new Gson();
//        Logger.i("json:----------" + gson.toJson(logFilterBean));
//        Call<LogResultBean> logCall = logService.logFilterStatus(gson.toJson(logFilterBean));
//        logCall.enqueue(new Callback<LogResultBean>() {
//            @Override
//            public void onResponse(Call<LogResultBean> call, Response<LogResultBean> response) {
//                Logger.i("返回值-------------------" + response.body());
//            }
//
//            @Override
//            public void onFailure(Call<LogResultBean> call, Throwable t) {
//                Logger.i("失败-------------------" + t.getMessage());
//            }
//        });
//    }
//
//
//    public static void logFilterWithLinstener(String eventType, final Loglistener loglister) {
//        LogFilterBean logFilterBean = new LogFilterBean();
//        logFilterBean.setBrowserBrand(DeviceUtils.getSystemModel());
//        logFilterBean.setBrowserVersion(DeviceUtils.getSystemVersion());
//        logFilterBean.setBrowserHeight(String.valueOf(DensityUtils.getWindowHeight2(MyApplication.getInstance())));
//        logFilterBean.setBrowserWith(String.valueOf(DensityUtils.getWindowWidth2(MyApplication.getInstance())));
//        logFilterBean.setCity(SharePreferenceUtils.getInstance(MyApplication.getInstance()).getAsString(ConstantsUtils.LOCATION_CITY, "北京市"));
//        logFilterBean.setIp(NetWorkUtils.getLocalIpAddress());
//        logFilterBean.setCookieId(DeviceUtils.getIMEString(MyApplication.getInstance()));
//        logFilterBean.setCreateTime(DateUtils.getFormatDateTime(System.currentTimeMillis()));
//        logFilterBean.setEventType(eventType);
//
//        if (MyApplication.getInstance().userLoginBean != null && MyApplication.getInstance().userLoginBean.getResult() != null) {
//            logFilterBean.setNickName(MyApplication.getInstance().userLoginBean.getResult().getNickName());
//            logFilterBean.setUserId(String.valueOf(MyApplication.getInstance().userLoginBean.getResult().getUserId()));
//        }
//
//        logFilterBean.setChannel(DeviceUtils.getAppMetaData(MyApplication.getInstance(), ConstantsUtils.UMENG_CHANNEL));//渠道
//        logFilterBean.setFrom(PreferenceUtils.getString(ConstantsUtils.SHARE_BROADCAST_SOURCE, ConstantsUtils.EMPTY_STR));//这个是linkedMe中的source属性
//
//        OkHttpClient.Builder builder = HttpManager.getUnsafeOkHttpClient().newBuilder();
//        builder.addInterceptor(new LoggingInterceptor());
//
//        Retrofit retrofit = new Retrofit.Builder()
//                .client(builder.build())
//                .baseUrl(AppUtil.HTTP_BASE_URL)
//                .addConverterFactory(GsonConverterFactory.create())
//                .build();
//
//        LogService logService = retrofit.create(LogService.class);
//        Gson gson = new Gson();
//        Logger.i("json:----------" + gson.toJson(logFilterBean));
//        Call<LogResultBean> logCall = logService.logFilterStatus(gson.toJson(logFilterBean));
//        logCall.enqueue(new Callback<LogResultBean>() {
//            @Override
//            public void onResponse(Call<LogResultBean> call, Response<LogResultBean> response) {
//                Logger.i("返回值-------------------" + response.body());
//                if (loglister != null) {
//                    loglister.next();
//                }
//            }
//
//            @Override
//            public void onFailure(Call<LogResultBean> call, Throwable t) {
//                Logger.i("失败-------------------" + t.getMessage());
//                if (loglister != null) {
//                    loglister.next();
//                }
//            }
//        });
//    }
//
//    public static void logFilterWithLogo(String logo) {
//        LogFilterBean logFilterBean = new LogFilterBean();
//        logFilterBean.setBrowserBrand(DeviceUtils.getSystemModel());
//        logFilterBean.setBrowserVersion(DeviceUtils.getSystemVersion());
//        logFilterBean.setBrowserHeight(String.valueOf(DensityUtils.getWindowHeight2(MyApplication.getInstance())));
//        logFilterBean.setBrowserWith(String.valueOf(DensityUtils.getWindowWidth2(MyApplication.getInstance())));
//        logFilterBean.setCity(SharePreferenceUtils.getInstance(MyApplication.getInstance()).getAsString(ConstantsUtils.LOCATION_CITY, "北京市"));
//        logFilterBean.setIp(NetWorkUtils.getLocalIpAddress());
//        logFilterBean.setCookieId(DeviceUtils.getIMEString(MyApplication.getInstance()));
//        logFilterBean.setCreateTime(DateUtils.getFormatDateTime(System.currentTimeMillis()));
//        logFilterBean.setLogo(logo);
//        logFilterBean.setType(9);
//
//
//        if (MyApplication.getInstance().userLoginBean != null && MyApplication.getInstance().userLoginBean.getResult() != null) {
//            logFilterBean.setNickName(MyApplication.getInstance().userLoginBean.getResult().getNickName());
//            logFilterBean.setUserId(String.valueOf(MyApplication.getInstance().userLoginBean.getResult().getUserId()));
//        }
//
//        logFilterBean.setChannel(DeviceUtils.getAppMetaData(MyApplication.getInstance(), ConstantsUtils.UMENG_CHANNEL));//渠道
//        logFilterBean.setFrom(PreferenceUtils.getString(ConstantsUtils.SHARE_BROADCAST_SOURCE, ConstantsUtils.EMPTY_STR));//这个是linkedMe中的source属性
//
//        OkHttpClient.Builder builder = HttpManager.getUnsafeOkHttpClient().newBuilder();
//        builder.addInterceptor(new LoggingInterceptor());
//
//        Retrofit retrofit = new Retrofit.Builder()
//                .client(builder.build())
//                .baseUrl(AppUtil.HTTP_BASE_URL)
//                .addConverterFactory(GsonConverterFactory.create())
//                .build();
//
//        LogService logService = retrofit.create(LogService.class);
//        Gson gson = new Gson();
//        Logger.i("json:----------" + gson.toJson(logFilterBean));
//        Call<LogResultBean> logCall = logService.logFilterStatus(gson.toJson(logFilterBean));
//        logCall.enqueue(new Callback<LogResultBean>() {
//            @Override
//            public void onResponse(Call<LogResultBean> call, Response<LogResultBean> response) {
//                Logger.i("返回值-------------------" + response.body());
//            }
//
//            @Override
//            public void onFailure(Call<LogResultBean> call, Throwable t) {
//                Logger.i("失败-------------------" + t.getMessage());
//            }
//        });
//    }
//
//    public static interface Loglistener {
//        public void next();
//    }
//
//
//}
